package com.example.administrator.xxnapp.splash;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.example.administrator.xxnapp.BaseActivity;
import com.example.administrator.xxnapp.R;
import com.example.administrator.xxnapp.login.LoginActivity;
import com.example.administrator.xxnapp.main.MainActivity;
import com.example.administrator.xxnapp.util.Config;

public class SplashActivity extends BaseActivity {
    private static long SPLASH_TIME = 2000;
    private SharedPreferences preferences;
    private Handler mHandler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            if (preferences.getBoolean(Config.ShareKey.REMEMBER_PASSWORD_KEY,false)){
                startActivity(new Intent(mContext, MainActivity.class));
            }else {
                startActivity(new Intent(mContext, LoginActivity.class));
            }
            SplashActivity.this.finish();
        }
    };

    @Override
    public void initView() {

    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    public void initBeforeDatas() {
        preferences = getSharedPreferences(Config.ShareKey.SHARED_PREFRENCES_NAME,MODE_PRIVATE);
    }

    @Override
    public void setListeners() {
        mHandler.sendEmptyMessageDelayed(0x00,SPLASH_TIME);;
    }
}
